<template>
  <div class="index">
    <h3>请输入标题</h3>
    <el-input v-model="input" placeholder="请输入内容"></el-input>
    <h3>请输入内容</h3>
    <div id="editorElem" style="text-align:left"></div>
    <el-button type="primary" round class="s-submit" @click="addArtical">提交</el-button>
    <p>标题{{input}}</p>
    <p>内容{{content}}</p>
  </div>
</template>

<script>
  import E from 'wangeditor'

  export default {
    data() {
      return {
        input: 'sjfkdjkf',
        content: '222'
      }
    }
    , mounted() {
      var editor = new E('#editorElem')
      editor.customConfig.onchange = (html) => {
        this.content = html;
      }
      editor.create()
    }  ,
    methods:{
      addArtical:function () {
          let data={
              title:this.input,
              content:this.content
          };
          let postData=JSON.stringify({'data':data});
          this.$http.post('http://localhost:8000/artical',postData).then(data=>{
            alert('添加成功');
          })
      }
    }
  }
</script>

<style scoped>
.s-submit{width: 100%;}
</style>
